<template>
    <div id="OrdersTitle">
        <v-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules" @pop="setdata"></v-details>
    </div>
</template>

<script>
    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        props: {
            inputData: {
                type: Object,
            }
        },
        mixins: [baseMixin],
        name: "OrdersTitle",
        data() {
            return {
                rules: {},
                addflag: true,
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "table",
                            label: this.$t('bill.customer'),
                            props: "cust_code",
                            tableConfig: [
                                {
                                    label: this.$t('bill.customer'),
                                    prop: "cust_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t('common.desc'),
                                    prop: "cust_desc",
                                    input: "input",
                                },
                            ],
                            url: `/queryRpt/1/?/${this.$store.state.wms}`
                        },
                        {
                            type: "input",
                            label: this.$t('common.desc'),
                            props: "contract_desc",
                        },
                        {
                            type: "date",
                            label: this.$t('app.effectiveDate'),
                            props: "effective_date",
                        },
                        {
                            type: "table",
                            label: this.$t('bill.invoicedesc'),
                            props: "invoice_terms",
                            tableConfig: [
                                {
                                    label: this.$t('bill.invoicedesc'),
                                    prop: "invoice_terms",
                                    input: "input",
                                },
                                {
                                    label: this.$t('common.desc'),
                                    prop: "terms_desc",
                                    input: "input",
                                },
                            ],
                            url: `/queryTermList/${this.$store.state.wms}/`
                        },
                    ]
                ]

            }
        },
        methods: {
            setdata(data, id, close, listId) {
                if (id == "0") {
                    this.inputData.cust_code = data.cust_code;
                } else if (id == "3") {
                    this.inputData.invoice_terms = data.invoice_terms;
                }
                close(false);
            }
        },
        mounted() {
            if (Object.keys(this.$store.state.skip).length != 0) {
                let data = this.$store.state.skip;
                if (!data.newFlag) {
                    this.addflag = true;
                }
            } else if (this.$store.state.temporary != "") {
                this.addflag = false;
            } else if (!this.$store.state.newFlag) {
                this.addflag = true;
            } else {
                this.addflag = false;
            }
        },
        watch: {},
        components: {
            'v-details': details
        }
    }
</script>

<style scoped>

</style>
